Imports System.Net
Imports System.IO


Delegate Sub FunctionCall(ByVal param)



Public Class lblLoginSuccess
    Inherits System.Windows.Forms.Form
    Implements DPFP.Capture.EventHandler

#Region " Windows Form Designer generated code "



    'Form overrides dispose to clean up the component list.
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing Then
            If Not (components Is Nothing) Then
                components.Dispose()
            End If
        End If
        MyBase.Dispose(disposing)
    End Sub

    'Required by the Windows Form Designer
    Private components As System.ComponentModel.IContainer

    'NOTE: The following procedure is required by the Windows Form Designer
    'It can be modified using the Windows Form Designer.  
    'Do not modify it using the code editor.
    Friend WithEvents GroupBox3 As System.Windows.Forms.GroupBox
    Friend WithEvents txtLoggerName As System.Windows.Forms.TextBox
    Friend WithEvents Label4 As System.Windows.Forms.Label
    Friend WithEvents grpFPScan As System.Windows.Forms.GroupBox
    Friend WithEvents Timer1 As System.Windows.Forms.Timer
    Friend WithEvents Button3 As System.Windows.Forms.Button
    Friend WithEvents GroupBox1 As System.Windows.Forms.GroupBox
    Friend WithEvents Label8 As System.Windows.Forms.Label
    Friend WithEvents StatusLine As System.Windows.Forms.Label
    Private WithEvents Picture As System.Windows.Forms.PictureBox
    Friend WithEvents PromptLine As System.Windows.Forms.Label
    Friend WithEvents lblVerifyFail As System.Windows.Forms.Label
    Friend WithEvents lblVerifySuccess As System.Windows.Forms.Label
    Friend WithEvents VerifyTimer As System.Windows.Forms.Timer
    Friend WithEvents btnLogout As System.Windows.Forms.Button
    Friend WithEvents btnLogin As System.Windows.Forms.Button
    Friend WithEvents grpLog As System.Windows.Forms.GroupBox
    Friend WithEvents grpManualLog As System.Windows.Forms.GroupBox
    Friend WithEvents Label3 As System.Windows.Forms.Label
    Friend WithEvents Label1 As System.Windows.Forms.Label
    Friend WithEvents txtPassword As System.Windows.Forms.TextBox
    Friend WithEvents txtUsername As System.Windows.Forms.TextBox
    Friend WithEvents lblMFail As System.Windows.Forms.Label
    Friend WithEvents lblMSuccess As System.Windows.Forms.Label
    Friend WithEvents cbManual As System.Windows.Forms.CheckBox
    Friend WithEvents Label2 As System.Windows.Forms.Label
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Me.components = New System.ComponentModel.Container()
        Dim lblPrompt As System.Windows.Forms.Label
        Dim Label7 As System.Windows.Forms.Label
        Dim Label5 As System.Windows.Forms.Label
        Dim lblMDone As System.Windows.Forms.Label
        Me.GroupBox3 = New System.Windows.Forms.GroupBox()
        Me.txtLoggerName = New System.Windows.Forms.TextBox()
        Me.Label4 = New System.Windows.Forms.Label()
        Me.lblVerifyFail = New System.Windows.Forms.Label()
        Me.lblVerifySuccess = New System.Windows.Forms.Label()
        Me.grpFPScan = New System.Windows.Forms.GroupBox()
        Me.Picture = New System.Windows.Forms.PictureBox()
        Me.Timer1 = New System.Windows.Forms.Timer(Me.components)
        Me.Button3 = New System.Windows.Forms.Button()
        Me.GroupBox1 = New System.Windows.Forms.GroupBox()
        Me.Label2 = New System.Windows.Forms.Label()
        Me.Label8 = New System.Windows.Forms.Label()
        Me.StatusLine = New System.Windows.Forms.Label()
        Me.PromptLine = New System.Windows.Forms.Label()
        Me.VerifyTimer = New System.Windows.Forms.Timer(Me.components)
        Me.btnLogin = New System.Windows.Forms.Button()
        Me.btnLogout = New System.Windows.Forms.Button()
        Me.grpLog = New System.Windows.Forms.GroupBox()
        Me.grpManualLog = New System.Windows.Forms.GroupBox()
        Me.lblMSuccess = New System.Windows.Forms.Label()
        Me.lblMFail = New System.Windows.Forms.Label()
        Me.txtPassword = New System.Windows.Forms.TextBox()
        Me.txtUsername = New System.Windows.Forms.TextBox()
        Me.Label3 = New System.Windows.Forms.Label()
        Me.Label1 = New System.Windows.Forms.Label()
        Me.cbManual = New System.Windows.Forms.CheckBox()
        lblPrompt = New System.Windows.Forms.Label()
        Label7 = New System.Windows.Forms.Label()
        Label5 = New System.Windows.Forms.Label()
        lblMDone = New System.Windows.Forms.Label()
        Me.GroupBox3.SuspendLayout()
        Me.grpFPScan.SuspendLayout()
        CType(Me.Picture, System.ComponentModel.ISupportInitialize).BeginInit()
        Me.GroupBox1.SuspendLayout()
        Me.grpLog.SuspendLayout()
        Me.grpManualLog.SuspendLayout()
        Me.SuspendLayout()
        '
        'lblPrompt
        '
        lblPrompt.Anchor = CType((((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Bottom) _
                    Or System.Windows.Forms.AnchorStyles.Left) _
                    Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
        lblPrompt.Location = New System.Drawing.Point(134, 56)
        lblPrompt.Margin = New System.Windows.Forms.Padding(4, 0, 4, 0)
        lblPrompt.Name = "lblPrompt"
        lblPrompt.Size = New System.Drawing.Size(559, 93)
        lblPrompt.TabIndex = 7
        lblPrompt.Text = "To verify your identity, touch fingerprint reader with any enrolled finger."
        '
        'Label7
        '
        Label7.Anchor = CType((((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Bottom) _
                    Or System.Windows.Forms.AnchorStyles.Left) _
                    Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
        Label7.Font = New System.Drawing.Font("Arial", 8.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Label7.ForeColor = System.Drawing.Color.Red
        Label7.Location = New System.Drawing.Point(476, 130)
        Label7.Margin = New System.Windows.Forms.Padding(4, 0, 4, 0)
        Label7.Name = "Label7"
        Label7.Size = New System.Drawing.Size(186, 35)
        Label7.TabIndex = 23
        Label7.Text = "Back"
        Label7.TextAlign = System.Drawing.ContentAlignment.TopCenter
        AddHandler Label7.Click, AddressOf Me.Label7_Click
        '
        'Label5
        '
        Label5.Anchor = CType((((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Bottom) _
                    Or System.Windows.Forms.AnchorStyles.Left) _
                    Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
        Label5.Font = New System.Drawing.Font("Arial", 8.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Label5.ForeColor = System.Drawing.Color.Red
        Label5.Location = New System.Drawing.Point(434, 130)
        Label5.Margin = New System.Windows.Forms.Padding(4, 0, 4, 0)
        Label5.Name = "Label5"
        Label5.Size = New System.Drawing.Size(228, 22)
        Label5.TabIndex = 24
        Label5.Text = "Back"
        Label5.TextAlign = System.Drawing.ContentAlignment.TopCenter
        AddHandler Label5.Click, AddressOf Me.Label5_Click
        '
        'lblMDone
        '
        lblMDone.Anchor = CType((((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Bottom) _
                    Or System.Windows.Forms.AnchorStyles.Left) _
                    Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
        lblMDone.Font = New System.Drawing.Font("Arial", 8.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        lblMDone.ForeColor = System.Drawing.SystemColors.HotTrack
        lblMDone.Location = New System.Drawing.Point(99, 130)
        lblMDone.Margin = New System.Windows.Forms.Padding(4, 0, 4, 0)
        lblMDone.Name = "lblMDone"
        lblMDone.Size = New System.Drawing.Size(299, 22)
        lblMDone.TabIndex = 25
        lblMDone.Text = "Login/Logout"
        lblMDone.TextAlign = System.Drawing.ContentAlignment.TopCenter
        AddHandler lblMDone.Click, AddressOf Me.lblMDone_Click
        '
        'GroupBox3
        '
        Me.GroupBox3.Controls.Add(Me.txtLoggerName)
        Me.GroupBox3.Controls.Add(Me.Label4)
        Me.GroupBox3.FlatStyle = System.Windows.Forms.FlatStyle.Flat
        Me.GroupBox3.Font = New System.Drawing.Font("Arial", 12.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.GroupBox3.ForeColor = System.Drawing.SystemColors.ControlText
        Me.GroupBox3.Location = New System.Drawing.Point(16, 321)
        Me.GroupBox3.Name = "GroupBox3"
        Me.GroupBox3.Size = New System.Drawing.Size(696, 103)
        Me.GroupBox3.TabIndex = 15
        Me.GroupBox3.TabStop = False
        Me.GroupBox3.Text = "Employee Information"
        '
        'txtLoggerName
        '
        Me.txtLoggerName.BackColor = System.Drawing.Color.LightGray
        Me.txtLoggerName.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
        Me.txtLoggerName.Font = New System.Drawing.Font("Arial", 12.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.txtLoggerName.Location = New System.Drawing.Point(210, 37)
        Me.txtLoggerName.Name = "txtLoggerName"
        Me.txtLoggerName.ReadOnly = True
        Me.txtLoggerName.Size = New System.Drawing.Size(409, 35)
        Me.txtLoggerName.TabIndex = 3
        Me.txtLoggerName.TabStop = False
        '
        'Label4
        '
        Me.Label4.Location = New System.Drawing.Point(37, 37)
        Me.Label4.Name = "Label4"
        Me.Label4.Size = New System.Drawing.Size(105, 38)
        Me.Label4.TabIndex = 0
        Me.Label4.Text = "Name:"
        Me.Label4.TextAlign = System.Drawing.ContentAlignment.MiddleLeft
        '
        'lblVerifyFail
        '
        Me.lblVerifyFail.ForeColor = System.Drawing.Color.FromArgb(CType(CType(192, Byte), Integer), CType(CType(0, Byte), Integer), CType(CType(0, Byte), Integer))
        Me.lblVerifyFail.Location = New System.Drawing.Point(16, 427)
        Me.lblVerifyFail.Name = "lblVerifyFail"
        Me.lblVerifyFail.Size = New System.Drawing.Size(696, 38)
        Me.lblVerifyFail.TabIndex = 5
        Me.lblVerifyFail.Text = "FINGERPRINT NOT VERIFIED"
        Me.lblVerifyFail.TextAlign = System.Drawing.ContentAlignment.MiddleCenter
        Me.lblVerifyFail.Visible = False
        '
        'lblVerifySuccess
        '
        Me.lblVerifySuccess.ForeColor = System.Drawing.Color.FromArgb(CType(CType(0, Byte), Integer), CType(CType(192, Byte), Integer), CType(CType(0, Byte), Integer))
        Me.lblVerifySuccess.Location = New System.Drawing.Point(11, 428)
        Me.lblVerifySuccess.Name = "lblVerifySuccess"
        Me.lblVerifySuccess.Size = New System.Drawing.Size(690, 38)
        Me.lblVerifySuccess.TabIndex = 4
        Me.lblVerifySuccess.Text = "FINGERPRINT VERIFIED"
        Me.lblVerifySuccess.TextAlign = System.Drawing.ContentAlignment.MiddleCenter
        Me.lblVerifySuccess.Visible = False
        '
        'grpFPScan
        '
        Me.grpFPScan.BackColor = System.Drawing.Color.Linen
        Me.grpFPScan.Controls.Add(Label7)
        Me.grpFPScan.Controls.Add(Me.Picture)
        Me.grpFPScan.Controls.Add(lblPrompt)
        Me.grpFPScan.FlatStyle = System.Windows.Forms.FlatStyle.Flat
        Me.grpFPScan.Font = New System.Drawing.Font("Arial", 12.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.grpFPScan.ForeColor = System.Drawing.SystemColors.ControlText
        Me.grpFPScan.Location = New System.Drawing.Point(12, 147)
        Me.grpFPScan.Name = "grpFPScan"
        Me.grpFPScan.Size = New System.Drawing.Size(699, 168)
        Me.grpFPScan.TabIndex = 11
        Me.grpFPScan.TabStop = False
        Me.grpFPScan.Text = "Fingerprint Scanner"
        Me.grpFPScan.Visible = False
        '
        'Picture
        '
        Me.Picture.Anchor = CType(((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Bottom) _
                    Or System.Windows.Forms.AnchorStyles.Left), System.Windows.Forms.AnchorStyles)
        Me.Picture.BackColor = System.Drawing.SystemColors.Window
        Me.Picture.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D
        Me.Picture.Location = New System.Drawing.Point(16, 37)
        Me.Picture.Margin = New System.Windows.Forms.Padding(4, 5, 4, 5)
        Me.Picture.Name = "Picture"
        Me.Picture.Size = New System.Drawing.Size(102, 102)
        Me.Picture.TabIndex = 21
        Me.Picture.TabStop = False
        '
        'Timer1
        '
        Me.Timer1.Interval = 1000
        '
        'Button3
        '
        Me.Button3.BackColor = System.Drawing.SystemColors.Control
        Me.Button3.Font = New System.Drawing.Font("Microsoft Sans Serif", 12.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.Button3.ForeColor = System.Drawing.SystemColors.ControlText
        Me.Button3.Location = New System.Drawing.Point(85, 470)
        Me.Button3.Name = "Button3"
        Me.Button3.Size = New System.Drawing.Size(565, 56)
        Me.Button3.TabIndex = 16
        Me.Button3.Text = "System Interface"
        Me.Button3.UseVisualStyleBackColor = False
        '
        'GroupBox1
        '
        Me.GroupBox1.Controls.Add(Me.Label2)
        Me.GroupBox1.FlatStyle = System.Windows.Forms.FlatStyle.Flat
        Me.GroupBox1.Font = New System.Drawing.Font("Arial", 12.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.GroupBox1.ForeColor = System.Drawing.SystemColors.ControlText
        Me.GroupBox1.Location = New System.Drawing.Point(13, 12)
        Me.GroupBox1.Name = "GroupBox1"
        Me.GroupBox1.Size = New System.Drawing.Size(699, 95)
        Me.GroupBox1.TabIndex = 12
        Me.GroupBox1.TabStop = False
        Me.GroupBox1.Text = " Date and Time"
        '
        'Label2
        '
        Me.Label2.Font = New System.Drawing.Font("Arial", 14.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.Label2.ForeColor = System.Drawing.Color.Brown
        Me.Label2.Location = New System.Drawing.Point(82, 31)
        Me.Label2.Name = "Label2"
        Me.Label2.Size = New System.Drawing.Size(537, 58)
        Me.Label2.TabIndex = 0
        Me.Label2.TextAlign = System.Drawing.ContentAlignment.MiddleCenter
        '
        'Label8
        '
        Me.Label8.Font = New System.Drawing.Font("Arial", 12.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.Label8.ForeColor = System.Drawing.SystemColors.ControlText
        Me.Label8.Location = New System.Drawing.Point(146, 529)
        Me.Label8.Name = "Label8"
        Me.Label8.Size = New System.Drawing.Size(451, 31)
        Me.Label8.TabIndex = 19
        Me.Label8.Text = "Click here to go to the System Interface"
        '
        'StatusLine
        '
        Me.StatusLine.Location = New System.Drawing.Point(24, 600)
        Me.StatusLine.Name = "StatusLine"
        Me.StatusLine.Size = New System.Drawing.Size(688, 38)
        Me.StatusLine.TabIndex = 20
        Me.StatusLine.Text = "[Status]"
        Me.StatusLine.TextAlign = System.Drawing.ContentAlignment.MiddleCenter
        '
        'PromptLine
        '
        Me.PromptLine.Location = New System.Drawing.Point(24, 562)
        Me.PromptLine.Name = "PromptLine"
        Me.PromptLine.Size = New System.Drawing.Size(688, 38)
        Me.PromptLine.TabIndex = 21
        Me.PromptLine.Text = "[Prompt]"
        Me.PromptLine.TextAlign = System.Drawing.ContentAlignment.MiddleCenter
        Me.PromptLine.Visible = False
        '
        'VerifyTimer
        '
        '
        'btnLogin
        '
        Me.btnLogin.BackColor = System.Drawing.SystemColors.Control
        Me.btnLogin.Font = New System.Drawing.Font("Microsoft Sans Serif", 12.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.btnLogin.ForeColor = System.Drawing.SystemColors.ControlText
        Me.btnLogin.Location = New System.Drawing.Point(24, 56)
        Me.btnLogin.Name = "btnLogin"
        Me.btnLogin.Size = New System.Drawing.Size(298, 56)
        Me.btnLogin.TabIndex = 22
        Me.btnLogin.Text = "Log In"
        Me.btnLogin.UseVisualStyleBackColor = False
        '
        'btnLogout
        '
        Me.btnLogout.BackColor = System.Drawing.SystemColors.Control
        Me.btnLogout.Font = New System.Drawing.Font("Microsoft Sans Serif", 12.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.btnLogout.ForeColor = System.Drawing.SystemColors.ControlText
        Me.btnLogout.Location = New System.Drawing.Point(378, 56)
        Me.btnLogout.Name = "btnLogout"
        Me.btnLogout.Size = New System.Drawing.Size(315, 56)
        Me.btnLogout.TabIndex = 23
        Me.btnLogout.Text = "Log Out"
        Me.btnLogout.UseVisualStyleBackColor = False
        '
        'grpLog
        '
        Me.grpLog.Controls.Add(Me.cbManual)
        Me.grpLog.Controls.Add(Me.btnLogin)
        Me.grpLog.Controls.Add(Me.btnLogout)
        Me.grpLog.FlatStyle = System.Windows.Forms.FlatStyle.Flat
        Me.grpLog.Font = New System.Drawing.Font("Arial", 12.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.grpLog.ForeColor = System.Drawing.SystemColors.ControlText
        Me.grpLog.Location = New System.Drawing.Point(12, 147)
        Me.grpLog.Name = "grpLog"
        Me.grpLog.Size = New System.Drawing.Size(699, 165)
        Me.grpLog.TabIndex = 13
        Me.grpLog.TabStop = False
        Me.grpLog.Text = "Log In/Out"
        '
        'grpManualLog
        '
        Me.grpManualLog.Controls.Add(lblMDone)
        Me.grpManualLog.Controls.Add(Label5)
        Me.grpManualLog.Controls.Add(Me.txtPassword)
        Me.grpManualLog.Controls.Add(Me.txtUsername)
        Me.grpManualLog.Controls.Add(Me.Label3)
        Me.grpManualLog.Controls.Add(Me.Label1)
        Me.grpManualLog.FlatStyle = System.Windows.Forms.FlatStyle.Flat
        Me.grpManualLog.Font = New System.Drawing.Font("Arial", 12.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.grpManualLog.ForeColor = System.Drawing.SystemColors.ControlText
        Me.grpManualLog.Location = New System.Drawing.Point(12, 147)
        Me.grpManualLog.Name = "grpManualLog"
        Me.grpManualLog.Size = New System.Drawing.Size(699, 168)
        Me.grpManualLog.TabIndex = 22
        Me.grpManualLog.TabStop = False
        Me.grpManualLog.Text = "Manual Log"
        Me.grpManualLog.Visible = False
        '
        'lblMSuccess
        '
        Me.lblMSuccess.Font = New System.Drawing.Font("Arial", 8.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.lblMSuccess.ForeColor = System.Drawing.Color.DarkSeaGreen
        Me.lblMSuccess.Location = New System.Drawing.Point(13, 438)
        Me.lblMSuccess.Name = "lblMSuccess"
        Me.lblMSuccess.Size = New System.Drawing.Size(700, 32)
        Me.lblMSuccess.TabIndex = 11
        Me.lblMSuccess.Text = "USER ACCOUNT VERIFIED"
        Me.lblMSuccess.TextAlign = System.Drawing.ContentAlignment.MiddleCenter
        Me.lblMSuccess.Visible = False
        '
        'lblMFail
        '
        Me.lblMFail.Font = New System.Drawing.Font("Arial", 8.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.lblMFail.ForeColor = System.Drawing.Color.FromArgb(CType(CType(192, Byte), Integer), CType(CType(0, Byte), Integer), CType(CType(0, Byte), Integer))
        Me.lblMFail.Location = New System.Drawing.Point(9, 438)
        Me.lblMFail.Name = "lblMFail"
        Me.lblMFail.Size = New System.Drawing.Size(699, 32)
        Me.lblMFail.TabIndex = 10
        Me.lblMFail.Text = "Username does not exist or Password is incorrect"
        Me.lblMFail.TextAlign = System.Drawing.ContentAlignment.MiddleCenter
        Me.lblMFail.Visible = False
        '
        'txtPassword
        '
        Me.txtPassword.BackColor = System.Drawing.SystemColors.ButtonHighlight
        Me.txtPassword.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
        Me.txtPassword.Font = New System.Drawing.Font("Arial", 12.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.txtPassword.Location = New System.Drawing.Point(206, 83)
        Me.txtPassword.Margin = New System.Windows.Forms.Padding(4, 5, 4, 5)
        Me.txtPassword.Name = "txtPassword"
        Me.txtPassword.PasswordChar = Global.Microsoft.VisualBasic.ChrW(42)
        Me.txtPassword.Size = New System.Drawing.Size(246, 35)
        Me.txtPassword.TabIndex = 4
        '
        'txtUsername
        '
        Me.txtUsername.BackColor = System.Drawing.SystemColors.ButtonHighlight
        Me.txtUsername.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
        Me.txtUsername.Font = New System.Drawing.Font("Arial", 12.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.txtUsername.Location = New System.Drawing.Point(206, 37)
        Me.txtUsername.Margin = New System.Windows.Forms.Padding(4, 5, 4, 5)
        Me.txtUsername.Name = "txtUsername"
        Me.txtUsername.Size = New System.Drawing.Size(248, 35)
        Me.txtUsername.TabIndex = 3
        '
        'Label3
        '
        Me.Label3.Location = New System.Drawing.Point(30, 79)
        Me.Label3.Name = "Label3"
        Me.Label3.Size = New System.Drawing.Size(169, 38)
        Me.Label3.TabIndex = 2
        Me.Label3.Text = "Password"
        Me.Label3.TextAlign = System.Drawing.ContentAlignment.MiddleLeft
        '
        'Label1
        '
        Me.Label1.Location = New System.Drawing.Point(30, 37)
        Me.Label1.Name = "Label1"
        Me.Label1.Size = New System.Drawing.Size(169, 38)
        Me.Label1.TabIndex = 1
        Me.Label1.Text = "Username"
        Me.Label1.TextAlign = System.Drawing.ContentAlignment.MiddleLeft
        '
        'cbManual
        '
        Me.cbManual.AutoSize = True
        Me.cbManual.Font = New System.Drawing.Font("Arial", 8.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.cbManual.ForeColor = System.Drawing.SystemColors.Highlight
        Me.cbManual.Location = New System.Drawing.Point(24, 127)
        Me.cbManual.Name = "cbManual"
        Me.cbManual.Size = New System.Drawing.Size(211, 22)
        Me.cbManual.TabIndex = 23
        Me.cbManual.Text = "Use Manual Login/Logout"
        Me.cbManual.UseVisualStyleBackColor = True
        '
        'lblLoginSuccess
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(8, 19)
        Me.AutoSize = True
        Me.BackColor = System.Drawing.Color.Linen
        Me.ClientSize = New System.Drawing.Size(727, 637)
        Me.ControlBox = False
        Me.Controls.Add(Me.grpManualLog)
        Me.Controls.Add(Me.grpLog)
        Me.Controls.Add(Me.lblMFail)
        Me.Controls.Add(Me.lblMSuccess)
        Me.Controls.Add(Me.lblVerifySuccess)
        Me.Controls.Add(Me.lblVerifyFail)
        Me.Controls.Add(Me.PromptLine)
        Me.Controls.Add(Me.StatusLine)
        Me.Controls.Add(Me.Label8)
        Me.Controls.Add(Me.grpFPScan)
        Me.Controls.Add(Me.Button3)
        Me.Controls.Add(Me.GroupBox1)
        Me.Controls.Add(Me.GroupBox3)
        Me.DoubleBuffered = True
        Me.Font = New System.Drawing.Font("Arial", 8.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.ForeColor = System.Drawing.SystemColors.Highlight
        Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle
        Me.Name = "lblLoginSuccess"
        Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
        Me.Text = "  Employee Time-In Time-Out Interface"
        Me.GroupBox3.ResumeLayout(False)
        Me.GroupBox3.PerformLayout()
        Me.grpFPScan.ResumeLayout(False)
        CType(Me.Picture, System.ComponentModel.ISupportInitialize).EndInit()
        Me.GroupBox1.ResumeLayout(False)
        Me.grpLog.ResumeLayout(False)
        Me.grpLog.PerformLayout()
        Me.grpManualLog.ResumeLayout(False)
        Me.grpManualLog.PerformLayout()
        Me.ResumeLayout(False)

    End Sub

#End Region

#Region " Variable Declarations "


    Private Capturer As DPFP.Capture.Capture
    Private Enroller As EnrollmentForm
    Private BioArray As List(Of Biometrics)
    Private Verificator As New DPFP.Verification.Verification

    Private prevTime As DateTime
    Private verified As Boolean
    Private isLogin As Boolean = True
    Private inManualMode As Boolean = False

#End Region

#Region " Fingerprint Scanner Functions"

    Protected Sub StartCapture()
        If (Not Capturer Is Nothing) Then
            Try
                Capturer.StartCapture()
                SetPrompt("Using the fingerprint reader, scan your fingerprint.")
            Catch ex As Exception
                SetPrompt("Can't initiate capture!")
            End Try
        End If
    End Sub

    Protected Sub StopCapture()
        If (Not Capturer Is Nothing) Then
            Try
                Capturer.StopCapture()
            Catch ex As Exception
                SetPrompt("Can't terminate capture!")
            End Try
        End If
    End Sub

    Sub OnComplete(ByVal Capture As Object, ByVal ReaderSerialNumber As String, ByVal Sample As DPFP.Sample) Implements DPFP.Capture.EventHandler.OnComplete
        'MakeReport("The fingerprint sample was captured.")
        SetPrompt("Scan the same fingerprint again.")
        If grpFPScan.Visible = True Then Process(Sample)
    End Sub

    Sub OnFingerGone(ByVal Capture As Object, ByVal ReaderSerialNumber As String) Implements DPFP.Capture.EventHandler.OnFingerGone
        'MakeReport("The finger was removed from the fingerprint reader.")
    End Sub

    Sub OnFingerTouch(ByVal Capture As Object, ByVal ReaderSerialNumber As String) Implements DPFP.Capture.EventHandler.OnFingerTouch
        'MakeReport("The fingerprint reader was touched.")
    End Sub

    Sub OnReaderConnect(ByVal Capture As Object, ByVal ReaderSerialNumber As String) Implements DPFP.Capture.EventHandler.OnReaderConnect
        SetStatus("The fingerprint reader was connected.")
    End Sub

    Sub OnReaderDisconnect(ByVal Capture As Object, ByVal ReaderSerialNumber As String) Implements DPFP.Capture.EventHandler.OnReaderDisconnect
        SetStatus("The fingerprint reader was disconnected.")
    End Sub

    Sub OnSampleQuality(ByVal Capture As Object, ByVal ReaderSerialNumber As String, ByVal CaptureFeedback As DPFP.Capture.CaptureFeedback) Implements DPFP.Capture.EventHandler.OnSampleQuality
        'If CaptureFeedback = DPFP.Capture.CaptureFeedback.Good Then
        '    MakeReport("The quality of the fingerprint sample is good.")
        'Else
        '    MakeReport("The quality of the fingerprint sample is poor.")
        'End If
    End Sub

    Protected Overridable Sub Process(ByVal Sample As DPFP.Sample)
        DrawPicture(ConvertSampleToBitmap(Sample))
        Dim features As DPFP.FeatureSet = ExtractFeatures(Sample, DPFP.Processing.DataPurpose.Verification)

        ' Check quality of the sample and start verification if it's good
        If Not features Is Nothing Then

            Dim template As New DPFP.Template

            For Each bioObject As Biometrics In BioArray

                Dim b As Byte() = Convert.FromBase64String(bioObject.template_string.Replace("~", "+"))
                Dim ms As MemoryStream = New MemoryStream(b)
                template.DeSerialize(ms)

                Dim result As DPFP.Verification.Verification.Result = New DPFP.Verification.Verification.Result()
                Verificator.Verify(features, template, result)

                If result.Verified Then
                    verified = True
                    Dim empInfo As EmployeeInfo = New EmployeeInfoManager().retrieveEmployeeInfoByEmployeeId(bioObject.employee_id)

                    SetLoggerName(empInfo.last_name + ", " + empInfo.first_name + " " + empInfo.middle_name)
                    Dim biomgr As New BiometricsManager
                    If isLogin Then
                        biomgr.uploadLoginBio(bioObject)
                    Else
                        biomgr.uploadLogoutBio(bioObject)
                    End If

                    Exit For
                Else
                    verified = False
                End If


            Next
            prevTime = DateTime.Now
            VerifyTimer.Enabled = True

        End If

    End Sub

    Private Sub VerifyTimer_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles VerifyTimer.Tick
        'get the time elapsed since prevtime
        Dim ts As TimeSpan = DateTime.Now.Subtract(prevTime)

        VerifyPrompt(verified)

        If ts.Seconds > 5 Then
            DisableVerifyPrompt()
        End If

    End Sub

    Protected Function ConvertSampleToBitmap(ByVal Sample As DPFP.Sample) As Bitmap
        Dim convertor As New DPFP.Capture.SampleConversion()  ' Create a sample convertor.
        Dim bitmap As Bitmap = Nothing              ' TODO: the size doesn't matter
        convertor.ConvertToPicture(Sample, bitmap)        ' TODO: return bitmap as a result
        Return bitmap
    End Function


#End Region

    Public Sub New()
        InitializeComponent()


    End Sub

    Public Sub Init()
        'Initialize Label for Time and Timer
        Label2.Text = Format(Now, "yyyy-M-d HH:mm:ss")
        Timer1.Enabled = True

        'GET DATA FROM SERVER
        BioArray = GetDataFromServer()

        'Initialize Capturer
        Try
            Capturer = New DPFP.Capture.Capture()                   ' Create a capture operation.

            If (Not Capturer Is Nothing) Then
                Capturer.EventHandler = Me                              ' Subscribe for capturing events.
            Else
                MessageBox.Show("Can't initiate capture operation!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
            End If
        Catch ex As Exception
            MessageBox.Show("Can't initiate capture operation!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
        End Try
    End Sub

    Protected Function ExtractFeatures(ByVal Sample As DPFP.Sample, ByVal Purpose As DPFP.Processing.DataPurpose) As DPFP.FeatureSet
        Dim extractor As New DPFP.Processing.FeatureExtraction()    ' Create a feature extractor
        Dim feedback As DPFP.Capture.CaptureFeedback = DPFP.Capture.CaptureFeedback.None
        Dim features As New DPFP.FeatureSet()
        extractor.CreateFeatureSet(Sample, Purpose, feedback, features) ' TODO: return features as a result?
        If (feedback = DPFP.Capture.CaptureFeedback.Good) Then
            Return features
        Else
            Return Nothing
        End If
    End Function

    Private Function GetDataFromServer() As List(Of Biometrics)
        Dim biomgr As New BiometricsManager
        Dim bioarr As New List(Of Biometrics)
        bioarr = biomgr.retrieveBio()

        Return bioarr
    End Function

    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        Label2.Text = Format(Now, "yyyy-M-d HH:mm:ss")
    End Sub


    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        StopCapture()
        Me.Hide()
        Dim frmverifier As New VerificationForm(BioArray)
        frmverifier.ShowDialog()
        DisableVerifyPrompt()
    End Sub

    Private Sub DTRform_FormClosed(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosedEventArgs) Handles Me.FormClosed
        StopCapture()
    End Sub


    Private Sub DTRform_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Init()
        DisableVerifyPrompt()
    End Sub

    Protected Sub SetStatus(ByVal status)
        Invoke(New FunctionCall(AddressOf _SetStatus), status)
    End Sub

    Private Sub _SetStatus(ByVal status)
        StatusLine.Text = status
    End Sub

    Protected Sub DrawPicture(ByVal bmp)
        Invoke(New FunctionCall(AddressOf _DrawPicture), bmp)
    End Sub

    Private Sub _DrawPicture(ByVal bmp)
        Picture.Image = New Bitmap(bmp, Picture.Size)
    End Sub

    Protected Sub SetLoggerName(ByVal name As String)
        Invoke(New FunctionCall(AddressOf _SetLoggerName), name)
    End Sub

    Private Sub _SetLoggerName(ByVal name As String)
        txtLoggerName.Text = name
    End Sub

    Protected Sub VerifyPrompt(ByVal val As Boolean)
        Invoke(New FunctionCall(AddressOf _VerifyPrompt), val)
    End Sub
    Private Sub _VerifyPrompt(ByVal val As Boolean)
        'If verified show the success else show fail

        If Not inManualMode Then

            If val Then
                lblVerifySuccess.Show()
                lblVerifyFail.Hide()
                grpFPScan.Visible = False
                grpLog.Visible = True
            Else
                lblVerifyFail.Show()
                lblVerifySuccess.Hide()
            End If
        End If
       


       


    End Sub

    Protected Sub DisableVerifyPrompt()
        Invoke(New FunctionCall(AddressOf _DisableVerifyPrompt), False)
    End Sub

    Private Sub _DisableVerifyPrompt(ByVal dummy As Boolean)
        lblVerifyFail.Hide()
        lblVerifySuccess.Hide()
        lblMFail.Hide()
        lblMSuccess.Hide()
        VerifyTimer.Enabled = False
        Picture.Image = Nothing
        txtLoggerName.Text = ""

    End Sub



    Private Sub DTRform_VisibleChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.VisibleChanged
        If Me.Visible Then
            StartCapture()
            DisableVerifyPrompt()
            BioArray = GetDataFromServer()
            Timer1.Enabled = True
        Else
            StopCapture()
            Timer1.Enabled = False
        End If
    End Sub

    
    

    Protected Sub SetPrompt(ByVal prompt As String)
        Invoke(New FunctionCall(AddressOf _SetPrompt), prompt)
    End Sub
    Private Sub _SetPrompt(ByVal prompt)
        PromptLine.Text = prompt
    End Sub

    Private Sub btnLogin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLogin.Click
        isLogin = True
        

        If cbManual.Checked = True Then
            inManualMode = True
            grpManualLog.Visible = True
            grpLog.Visible = False
        Else
            inManualMode = False
            grpFPScan.Visible = True
            grpLog.Visible = False
        End If


    End Sub

    Private Sub btnLogout_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLogout.Click
        isLogin = False
        If cbManual.Checked = True Then
            inManualMode = True
            grpManualLog.Visible = True
            grpLog.Visible = False
        Else
            inManualMode = False
            grpFPScan.Visible = True
            grpLog.Visible = False
        End If

    End Sub

    Private Sub Label7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        grpFPScan.Visible = False
        grpLog.Visible = True

    End Sub

 

    Private Sub Label5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        grpManualLog.Visible = False
        grpLog.Visible = True
    End Sub

    Private Sub lblMDone_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        Dim logmgr As New LoginManager
        Dim emp As Employee
        emp = logmgr.login(txtUsername.Text, txtPassword.Text)
        If Not emp Is Nothing Then
            verified = True
            Dim biomgr As New BiometricsManager
            If isLogin Then
                biomgr.uploadLoginManual(emp.id.ToString)
            Else
                biomgr.uploadLogoutManual(emp.id.ToString)
            End If
            Dim empInfo As EmployeeInfo = New EmployeeInfoManager().retrieveEmployeeInfoByEmployeeId(emp.id)
            txtLoggerName.Text = empInfo.last_name + ", " + empInfo.first_name + " " + empInfo.middle_name
            lblMSuccess.Show()
            lblMFail.Hide()

            grpManualLog.Visible = False
            grpLog.Visible = True

        Else
            verified = False
            lblMFail.Show()
            lblMSuccess.Hide()

        End If
        prevTime = DateTime.Now
        VerifyTimer.Enabled = True
        txtUsername.Text = ""
        txtPassword.Text = ""
    End Sub

   

    
End Class
